import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/provide/bluetooth_provider.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:provider/provider.dart';

enum inputOutputType { input, output }

class InputOutputDialog extends StatefulWidget {
  final String bluetoothName;
  String btnName;
  VoidCallback onTapAction;
  inputOutputType type;
  TextEditingController vc;
  InputOutputDialog(
      {this.bluetoothName = '',
      required this.onTapAction,
      required this.vc,
      required this.btnName,
      required this.type});
  late BluetoothProvider bluetoothData;

  @override
  State<InputOutputDialog> createState() => _InputOutputDialogState();
}

class _InputOutputDialogState extends State<InputOutputDialog> {
  @override
  Widget build(BuildContext context) {
    widget.bluetoothData = context.watch<BluetoothProvider>();
    return Container(
      width: 320.0.W,
      height: 232.0.W,
      decoration: const BoxDecoration(
        gradient: LinearGradient(
            //渐变位置
            begin: Alignment.topCenter, //右上
            end: Alignment.bottomCenter, //左下
            //渐变颜色[始点颜色, 结束颜色]
            colors: [ColorPlate.app_blue, ColorPlate.sub_blue]),
        borderRadius: BorderRadius.all(Radius.circular(8.0)),
      ),
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            Container(
              padding: EdgeInsets.only(left: 24.0.W, right: 24.0.W),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.only(top: 20.0.W),
                    child: Text(
                      widget.type == inputOutputType.input
                          ? '导入拼接配置'
                          : "导出拼接配置",
                      style: StandardTextStyle.textWhite17Style,
                    ),
                  ),
                  widget.type == inputOutputType.input
                      ? Container(
                          padding: EdgeInsets.only(top: 42.0.W),
                          child: Stack(
                            children: [
                              Positioned(
                                top: 12,
                                child: Text(
                                  '链接',
                                  style: StandardTextStyle.textWhite17Style,
                                ),
                              ),
                              Container(
                                padding: EdgeInsets.fromLTRB(90, 0, 0, 0),
                                height: 50.0.W,
                                child: TextField(
                                    style: const TextStyle(color: Colors.white),
                                    controller: widget.vc,
                                    decoration: const InputDecoration(
                                      enabledBorder: UnderlineInputBorder(
                                        borderSide:
                                            BorderSide(color: Colors.blue),
                                      ),
                                      focusedBorder: UnderlineInputBorder(
                                        borderSide:
                                            BorderSide(color: Colors.blue),
                                      ),
                                    ),
                                    autofocus: true,
                                    cursorColor: ColorPlate.white),
                              ),
                            ],
                          ),
                        )
                      : Container(
                          padding: EdgeInsets.only(top: 40.0.W),
                          child: Text(
                            "链接文本文本问",
                            style: StandardTextStyle.textWhite17Style,
                          ),
                        ),
                  widget.type == inputOutputType.input
                      ? const Divider(
                          height: 1.0,
                          color: ColorPlate.white, // 分割线颜色
                        )
                      : Container(),
                ],
              ),
            ),
            Column(
              children: [
                Container(
                  padding: EdgeInsets.only(top: 40.0.W),
                  child: Divider(
                    height: 1.0.W,
                    color: ColorPlate.white, // 分割线颜色
                  ),
                ),
                Container(
                  height: 50.0.W,
                  child: Row(
                    children: [
                      Expanded(
                        child: InkWell(
                          onTap: () {
                            widget.onTapAction();
                            Navigator.pop(context);
                          },
                          child: Center(
                            child: Text(
                              widget.btnName,
                              style: StandardTextStyle.textWhite16Style,
                              textAlign: TextAlign.center,
                            ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
